<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>销售模块-销售产品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>
<style type="text/css">
    .xyg-upload-item{width: 80px; height: 100px; float: left; margin-left: 10px;}
    .xyg-upload-item img{height: 80px; width: auto; max-width: 80px;}
    .xyg-upload-item .xyg-upload-item-btn{width: 80px; height: 20px; line-height: 20px;}
    .xyg-upload-item .xyg-upload-item-btn-right{float: right;}
    .xyg-upload-item span{cursor: pointer;}
</style>
<body class="childrenBody">
<form class="layui-form">
    <input type="hidden" id="id" name="id" value="${ticketProduct.id}" />


    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label ">
            <span class="red">*</span>&nbsp;&nbsp;名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="name" value="${ticketProduct.name}" placeholder="请输入名称" lay-verify="required" autocomplete="off" /></div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;封面图</label>&nbsp;&nbsp;<span style="color: red;">图片宽为160px,高为160px。<a target="_blank" href="https://tinypng.com/">立即压缩</a> </span>
        <!--单图片开始-->
        <div class="layui-input-block cy-uploadpic-ctn" id="thumImage"  style=" float:left;margin:10px 0!important;position:relative; width: 90px; height: 90px;">
        </div>
        <!--单图片结束-->
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;轮播图</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <button type="button" class="layui-btn" id="image">立即上传</button>&nbsp;&nbsp;<span style="color: red;">图片宽为750px,高为320px。<a target="_blank" href="https://tinypng.com/">立即压缩</a> </span>
                <blockquote class="layui-elem-quote layui-quote-nm" id="imageContent" style="margin-top: 10px; height: 100px;">
                </blockquote>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-inline ">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;所属栏目</label>
            <div class="layui-input-block">
                <select class="form-control" name="colId" lay-verify="required" id="colId"></select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;门市价</label>
            <div class="layui-input-block">
                <input type="number" class="layui-input" name="costPrice" value="${ticketProduct.costPrice}" placeholder="请输入门市价" lay-verify="required" autocomplete="off" /></div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;现价</label>
            <div class="layui-input-block">
                <input type="number" class="layui-input" name="currentPrice" value="${ticketProduct.currentPrice}" placeholder="请输入现价" lay-verify="required" autocomplete="off" /></div>
        </div>


    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;供应商</label>
            <div class="layui-input-block">
                <select class="form-control" name="supplierId" lay-verify="required" id="supplierId"></select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red"></span>&nbsp;&nbsp;标签</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="tags" value="${ticketProduct.tags}" placeholder="请输入标签，多个用"  autocomplete="off" /></div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;评分</label>
            <div class="layui-input-block" id="score">
                <input type="number" maxlength="4" class="layui-input" name="score" value="${ticketProduct.score}" placeholder="请输入评分" lay-verify="required" autocomplete="off" />
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;是否展示</label>
            <div class="layui-input-block">
                <select class="form-control" name="showType" lay-verify="required" id="showType"></select>
            </div>
        </div>
        <div class="layui-inline ">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;一级分销</label>
            <div class="layui-input-block">
                <input type="number" class="layui-input" name="shareOneMoney" value="${ticketProduct.shareOneMoney!'0'}" placeholder="请输入一级分销金额，0表示不分销"  autocomplete="off" /></div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;二级分销</label>
            <div class="layui-input-block">
                <input type="number" class="layui-input" name="shareTwoMoney" value="${ticketProduct.shareTwoMoney!'0'}" placeholder="请输入二级分销金额，0表示不分销"  autocomplete="off" /></div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-inline">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;首页展示</label>
            <div class="layui-input-block">
                <select class="form-control" name="fristShow" lay-verify="required" id="fristShow"></select>
            </div>
        </div>
        <div class="layui-inline ">
            <label class="layui-form-label">
                <span class="red">*</span>&nbsp;&nbsp;排行榜展示</label>
            <div class="layui-input-block">
                <select class="form-control" name="rankShow" lay-verify="required" id="rankShow"></select>
            </div>
        </div>

    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red"></span>&nbsp;&nbsp;说明内容</label>
        <div class="layui-input-block">
            <textarea class="layui-textarea" id="content" name="content" placeholder="请输入说明内容">${ticketProduct.content}</textarea></div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red"></span>&nbsp;&nbsp;经纬度</label>
        <div class="layui-input-block">
            <div class="layui-input-inline" style="width: 200px;">
                <input type="text" class="layui-input" name="longitude" value="${ticketProduct.longitude}" placeholder="请输入经度(180到-180)"  autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 200px;">
                <input type="text" class="layui-input" name="latitude" value="${ticketProduct.latitude}" placeholder="请输入纬度(90到-90)" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid">
                <a href="https://lbs.amap.com/console/show/picker" target="_blank">查看经纬度</a>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;省市区</label>
        <div class="layui-input-inline">
            <select class="form-control" lay-filter="provinceId" name="provinceId" lay-verify="required" id="provinceId"></select>
        </div>
        <div class="layui-input-inline">
            <select class="form-control" lay-filter="cityId" name="cityId" lay-verify="required" id="cityId"></select>
        </div>
        <div class="layui-input-inline">
            <select class="form-control" lay-filter="areaId" name="areaId" lay-verify="required" id="areaId"></select>
        </div>
        <div class="layui-input-inline" style="width: 400px;">
            <input type="text" class="layui-input"  name="address" lay-verify="required"  value="${ticketProduct.address}" placeholder="请输入详细地址" autocomplete="off" class="layui-input">
        </div>

    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">
            <span class="red">*</span>&nbsp;&nbsp;排序号</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="sort" value="${ticketProduct.sort!'0'}" placeholder="请输入排序号，数据越大越往前" lay-verify="required" autocomplete="off" /></div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button></div>
    </div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript">layui.use(['form', 'jquery', 'baseUtil','dialogUtil','upload','fileUtil','pageUtil','richTxtUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
            upload = layui.upload,
            richTxtUtil = layui.richTxtUtil,
            dialogUtil = layui.dialogUtil,
            fileUtil = layui.fileUtil,
            baseUtil = layui.baseUtil,
            pageUtil = layui.pageUtil;

        //初始化
        var provinceId="provinceId";
        var cityId="cityId";
        var areaId="areaId";
        var provinceValue="${ticketProduct.provinceId}";
        var cityValue="${ticketProduct.cityId}";
        var areaValue="${ticketProduct.areaId}";
        pageUtil.initProvinces("provinceId",provinceValue,"cityId",cityValue,"areaId",areaValue);
        pageUtil.initDictByUrl("/ticketSupplier/acceptSelect","ticket_supplier_id",
            function(supplierDataUrl) {
        pageUtil.initDictByUrl("/ticketColumn/acceptSelect","ticket_col_type",
            function(dictDataUrl) {
                pageUtil.initDict("ticket_col_type,ticket_supplier_id,base_show_type",
                    function (dictData) {
                        pageUtil.showDict($("#colId"), pageUtil.aceeptDictContentList(dictDataUrl, "ticket_col_type"), "", '${ticketProduct.colId}');
                        pageUtil.showDict($("#supplierId"), pageUtil.aceeptDictContentList(supplierDataUrl, "ticket_supplier_id"), "", '${ticketProduct.supplierId}');
                        pageUtil.showDict($("#showType"), pageUtil.aceeptDictContentList(dictData, "base_show_type"), "", '${ticketProduct.showType}');
                        pageUtil.showDict($("#rankShow"), pageUtil.aceeptDictContentList(dictData, "base_show_type"), "", '${ticketProduct.rankShow}');
                        pageUtil.showDict($("#fristShow"), pageUtil.aceeptDictContentList(dictData, "base_show_type"), "", '${ticketProduct.fristShow}');
                    });
            });
            });
        //KnifeZ富文本
        var index=richTxtUtil.layeditKnifezBuild("content",300);

        var images='${ticketProduct.images}';
        if(images!=null&&images!=""){
            var imageList=images.split(",");
            for(var i=0;i<imageList.length;i++){
                var str='<div class="xyg-upload-item">'+
                    '<img src="'+imageList[i]+'" />'+
                    '<div class="xyg-upload-item-btn">'+
                    '<span class="xyg-upload-item-btn-show" data-url="'+imageList[i]+'">预览</span>'+
                    '<span class="xyg-upload-item-btn-right">删除</span>'+
                    '</div>'+
                    '</div>';
                $('#imageContent').append(str);
            }
        }
        $(document).on('click','.xyg-upload-item .xyg-upload-item-btn-show',function(){
            fileUtil.imageSingleShow($(this).attr("data-url"));
        });
        $(document).on('click','.xyg-upload-item .xyg-upload-item-btn-right',function(){
            var obj=$(this);
            dialogUtil.confirm("确定删除图片吗？",function () {
                obj.parent().parent().remove();
            });
        });

        //多图片上传
        upload.render({
            elem: '#image'
            , url: '/sysFile/singleFile' //上传接口
            , data:  {catalog: "host/item", requestFileType:"1",isSave:"2"}
            , done: function (result) {
                if (0 == result.code) {
                    var str='<div class="xyg-upload-item">'+
                        '<img src="'+result.data+'" />'+
                        '<div class="xyg-upload-item-btn">'+
                        '<span class="xyg-upload-item-btn-show" data-url="'+result.data+'">预览</span>'+
                        '<span class="xyg-upload-item-btn-right">删除</span>'+
                        '</div>'+
                        '</div>';
                    $('#imageContent').append(str);
                } else {
                    dialogUtil.msg(result.msg);
                }
            }
            ,multiple: true
            ,before: function(obj){

            }

        });
        //单图片上传
        fileUtil.uploadImageNoSave('thumImage',"ticket/product","${ticketProduct.thumImage}");
        form.on('submit(submitBtn)',
            function(data) {
                var images="";
                $("#imageContent .xyg-upload-item .xyg-upload-item-btn-show").each(function (index,obj) {
                    if(images==null||images==""){
                        images=$(obj).attr("data-url");
                    }else{
                        images+=","+$(obj).attr("data-url");
                    }
                });
                data.field.images=images;
                data.field.content=richTxtUtil.layeditBuildContent(index);
                baseUtil.postMethodResult("/ticketProduct/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });</script>
</body>

</html>